<style>
    .link-wrap{
        width: 800px;
        margin: 0 auto;
        margin-top: 100px;
    }
    .link-wrap h2{
        font-size: 26px;
        text-align: center;
    }
</style>
<div class="sm-rightPanel" id="ID_view_url">

    <input type="hidden" name="id" value="<%=id%>">

    <div class="link-wrap">
        <h2>投票</h2>
        <p style="text-align: center;color:#FF5722;">
            <img id="url_img" style="width: 100%;max-width:200px;">
        </p>
        <div class="layui-form-item">
            <label class="layui-form-label">链接</label>
            <button class="layui-btn btn-copy" style="float: right" data-clipboard-action="copy" data-clipboard-target="#websiteIndexUrl"><i class="icon-fuzhi iconfont"></i>复制</button>
            <div class="layui-input-block" style="margin-right: 100px;">
                <input id="websiteIndexUrl" type="text" name="url" readonly="" placeholder="请输入url" class="layui-input" value="/wxapi/gh_a37e6f06c1a9/message.html">
            </div>
        </div>
        <p style="text-align: center;color:#FF5722;margin-top: 10px;">
            微信扫描二维码分享或复制链接
        </p>
        <p style="text-align: center;color:#FF5722;margin-top: 10px;">
            分享前，请确认已完善企业信息！
        </p>
    </div>

</div>




<script>
    layui.use(['layer', "form"], function () {
        var $ = layui.$;
        var form = layui.form;
        var layer = layui.layer;
        form.render();

        getUrl();


        function getUrl() {

            var id = $("#ID_view_url").find("input[name='id']").val();

            $.ajax({
                type: "GET",
                url: '/paperInfo/viewUrl',
                data: {"id": id},
                success: function (result) {

                    console.log(result);

                    if (result.success) {
                        $("#websiteIndexUrl").val(result.data.paperUrl);
                        $("#url_img").attr("src",result.data.paperQRCodeUrl);

                    } else {
                        layer.msg("操作异常");
                    }

                    smartAui.loadJs("/js/plugin/clipboard/clipboard.min.js",function () {
                        var clipboard = new ClipboardJS('.btn-copy');
                        clipboard.on('success', function(e) {
                            layer.msg("复制成功！");
                        });

                        clipboard.on('error', function(e) {
                            layer.msg("复制失败！");
                        });
                    });
                }
            })
        }

    });
</script>

